package com.example.smartcity_poverty.ui.PersonalCenter.adapter

import android.app.Activity
import android.app.ActivityOptions
import android.content.Intent
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.R
import com.example.smartcity_poverty.ui.PersonalCenter.activity.ListActivity
import com.example.smartcity_poverty.ui.PersonalCenter.activity.LoginInfoActivity
import com.example.smartcity_poverty.ui.PersonalCenter.activity.NewContentActivity
import com.example.smartcity_poverty.ui.PersonalCenter.activity.NewPassWordActivity
import kotlinx.android.synthetic.main.re_item_person.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class PersonHomeAdapter(
    val list: MutableList<String>,
    private val layoutId: Int
) : BaseRecyclerAdapter<String>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: String,
        position: Int,
        holder: BaseViewHolder
    ) {
        if (list.size <= 0){

        }else{
            val d = list[position]
            holder.viewFind.personListImage.setImageResource(R.drawable.ic_baseline_person_24)
            holder.viewFind.personListName.text = d

            val con = holder.viewFind.view?.context
            holder.itemView.setOnClickListener {
                if (holder.viewFind.personListName.text.toString() == "个人信息"){
                    con?.startActivity(Intent(con, LoginInfoActivity::class.java))
                }

                if (holder.viewFind.personListName.text.toString() == "订单列表"){
                    val intent = Intent(con, ListActivity::class.java)
                    val options = ActivityOptions.makeSceneTransitionAnimation(con as Activity, holder.viewFind.personListImage, "robot")
                    con.startActivity(intent, options.toBundle())
                }

                if (holder.viewFind.personListName.text.toString() == "修改密码"){
                    con?.startActivity(Intent(con, NewPassWordActivity::class.java))
                }

                if (holder.viewFind.personListName.text.toString() == "意见反馈"){
                    con?.startActivity(Intent(con, NewContentActivity::class.java))

                }

            }
        }


    }
}